import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
// import { browserHistory } from 'react-router';
import { routerReducer as routing, routerMiddleware } from 'react-router-redux';
import reducers from '../reducers/index';

// const routeMiddleware = routerMiddleware(browserHistory);
const initialState = {};
let enhancer = null;

enhancer = compose()

const store = createStore(combineReducers({
    ...reducers, routing,
}), initialState, enhancer);


if (module.hot) {

    module.hot.accept('../reducers', () => {
        const reducers = require('../reducers').default;
        const combinedReducers = combineReducers({ ...reducers, routing });
        store.replaceReducer(combinedReducers);
    });

}

export default store;
